import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class SnackbarExample extends StatefulWidget {
  const SnackbarExample({super.key});

  @override
  State<SnackbarExample> createState() => _SnackbarExampleState();
}

class _SnackbarExampleState extends State<SnackbarExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Getx Snackbar"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Get.snackbar(
                  "Snackbar 标题", "欢迎使用Snackbar",
                  // colorText: Colors.pink,
                  duration: const Duration(
                    milliseconds: 5000,
                  ),
                  // snackPosition: SnackPosition.BOTTOM,
                  // titleText: Text("hahah"),
                  // messageText: Text("aslkdjlsakjdla s "),
                  icon: const Icon(Icons.ac_unit_sharp),
                  shouldIconPulse: false,
                  // maxWidth: 300,
                  // margin: const EdgeInsets.all(10),
                  // padding: const EdgeInsets.all(10),
                  // borderRadius: 50,
                  // borderWidth: 10,
                  // borderColor: Colors.greenAccent,
                  // leftBarIndicatorColor: Colors.red,
                  // boxShadows: [
                  //   const BoxShadow(
                  //     color: Colors.blue,
                  //     offset: Offset(10, 20),
                  //     spreadRadius: 20,
                  //     blurRadius: 10,
                  //   ),
                  // ],
                  // backgroundGradient: const LinearGradient(colors: [
                  //   Colors.red,
                  //   Colors.black,
                  // ]),
                  mainButton: TextButton(
                    onPressed: () {},
                    child: const Text(
                      "确认",
                      style: TextStyle(
                        color: Colors.greenAccent,
                      ),
                    ),
                  ),
                  onTap: (a) {
                    if (kDebugMode) {
                      print("点击了$a");
                    }
                  },
                  // isDismissible: false,
                  // dismissDirection: DismissDirection.horizontal,
                  // forwardAnimationCurve: Curves.bounceInOut,
                  // overlayBlur: 100,
                  snackbarStatus: (s) {
                    if (kDebugMode) {
                      print(s);
                    }
                  },
                );
              },
              child: const Text(
                "显示 Snackbar",
              ),
            ),
            ElevatedButton(
              onPressed: () {
                Get.back(result: "收到数据？${Get.arguments},再还你一点");
              },
              child: Text("收到数据？${Get.arguments},再还你一点"),
            )
          ],
        ),
      ),
    );
  }
}
